package com.lokiy.di

import kotlin.reflect.KClass

/**
 *
 * @author Lokiy
 * @date 2023-09-04 11:50
 */
object FragmentInfoItem {

    private val _items = mutableListOf<KClass<*>>()
    val items: List<KClass<*>>
        get() {
            check()
            return _items
        }

    @JvmStatic
    fun addFragment(fragmentName: String) {
        _items.add(Class.forName(fragmentName).kotlin)
    }

    private fun check() {
        if (_items.isEmpty()) {
            Class.forName(FragmentInfoConst.PKG + "." + FragmentInfoConst.NAME).getMethod(FragmentInfoConst.METHOD).invoke(null)
        }
    }

}